// import HubConnectionState from '../libs/signalr/signalr';

// import GameWS from "../Managers/GameWS";
// import LogicConfigTs from "./LogicConfigTs";
// import LanguageMngTs from "../Managers/LanguageMngTs";
import RoomTypes from "../Static/RoomTypes";

export default class GameLogicUtilTs {
    public static needStopDispatching : boolean = false
    //玩家主动与Websocket断开
    public static forceLogoutWs : boolean = false
    //玩家想要退出当前房间
    public static wantQuitRoom : boolean = false;
    //玩家想要进入的房间类型
    public static wantEnterRoomType : RoomTypes = null

    public static msgWathcerCallbacks = []

    // async startFindRoom (roomObj) {
    //     cc.log("尝试寻找房间：",roomObj)
    //     this.openGameScene(roomObj.id)
    //
    //     await cc.gg.toastMgr.showNetWaitting()
    //     let wsEnable = await this._checkWS()
    //     if(!wsEnable){  //目前socket未连接，等待连接上
    //         cc.find("Canvas").emit("msgwatcher_add",function () {
    //             if(GameWS.getState() === HubConnectionState.Connected){
    //                 cc.log("socket连接上了，开始寻找room")
    //                 this._doFindRoom(roomObj)
    //                 return true
    //             }
    //             return false
    //         }.bind(this))
    //     }else {
    //         this._doFindRoom(roomObj)
    //     }
    // }
    //
    // async _checkWS () {
    //     let wsStatus = GameWS.getState()
    //     cc.log(" 检查ws状态：",wsStatus)
    //     if(wsStatus !== HubConnectionState.Connected){
    //         return false
    //     }
    //
    //     return true
    // }
    //
    // openGameScene(mode){
    //     let roomMode = cc.gg.enumConfig.RoomMode
    //     let modeBase = mode & 0x0f0
    //     if(modeBase === roomMode.BASE_VALUE_2){
    //         cc.log("进入场景2")
    //         cc.gg.gameDataUtil.goToTwoPlayerGame()
    //     }else if(modeBase === roomMode.BASE_VALUE_6){
    //         cc.log("进入场景6")
    //         cc.gg.gameDataUtil.goToSixPlayerGame()
    //     }else {
    //         console.log("无法根据ID找到场景")
    //     }
    // }
    //
    // async _doFindRoom(roomObj){
    //     let type = roomObj.type
    //     let mode = roomObj.id
    //     let joker = true
    //     LogicConfigTs.LAST_ENTERED_ROOM = roomObj.id;
    //     let code = await GameWS.findRoom(type, mode, joker)
    //     if(!code){//success
    //         cc.gg.gameDataUtil.roomInfo = roomObj
    //     }else if(code == 2){//already has a room
    //         this._findRoomFailed(code)
    //     }else {
    //         cc.gg.toastMgr.removeNetWaitting()
    //         this._findRoomFailed(code)
    //     }
    // }
    //
    // _findRoomFailed (code) {
    //     if(code == 2){
    //         cc.log("已经在游戏中了")
    //     }else if(code == 5){
    //         let title = LanguageMngTs.getSentence(3)
    //         let btnStr = LanguageMngTs.getSentence(179)
    //         let buyStr = LanguageMngTs.getSentence(182)
    //         let contentStr = LanguageMngTs.getSentence(180)
    //         let cb = function () {
    //             cc.gg.toastMgr.removeDialog()
    //         }.bind(this)
    //         // cc.gg.toastMgr.showDialogOneButton(title,btnStr,contentStr,cb)
    //
    //         // cc.gg.toastMgr.showDialog(title,buyStr,btnStr,contentStr,
    //         //     function () {
    //         //         cc.gg.tdUtil.doSendTdEvent("show_wallet","MoneyNotEnough")
    //         //         cc.gg.toastMgr.removeDialog()
    //         //         this.uiMgr.tryToShowWallet()
    //         //     }.bind(this),
    //         //     cb
    //         // )
    //     }
    // }
}
